package platform.hwinfofetcher;

import java.io.File;
import java.io.IOException;

import model.Preference;
import model.Settings;
import util.PlayerUtilities;

public class LinuxHardwareInfoFetcher extends HardwareInfoFetcher {

	private String scriptFileName;

	public LinuxHardwareInfoFetcher() {
		scriptFileName = "getHardwareInfoLinux.sh";
	}

	@Override
	protected Process createProcess() throws IOException {
		ProcessBuilder pb = new ProcessBuilder("sh", scriptFileName);
		pb.directory(new File(Settings.SCRIPT_DIRECTORY));
		pb.environment().put("ROOT_PSWD", Preference.getInstance().getRootPassword());
		Process p = pb.start();
		return p;
	}

	@Override
	protected void createScript() {
		PlayerUtilities.copyFromJarToDirectory("scripts/" + scriptFileName, Settings.SCRIPT_DIRECTORY + scriptFileName);
	}

}
